﻿function AddFavorite(sURL, sTitle) {
    try {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e) {
        try {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e) {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
function SetHome(obj, vrl) {
    try {
        obj.style.behavior = 'url(#default#homepage)'; obj.setHomePage(vrl);
    }
    catch (e) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'");
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage', vrl);
        }
    }
}
$(function() {
    $(".left .mmenu dd:not(dd:has(dl))").mouseover(function() {
        $(this).addClass("over");
    });
    $(".left .mmenu dd:not(dd:has(dl))").mouseout(function() {
        $(this).removeClass("over");
    });


    $(".left .mmenu dt").click(function() {
        if ($(this.parentNode).hasClass("slideDown")) {
            $(this.parentNode).find("dd").not($.makeArray($(this.parentNode).find("dd dd"))).slideDown("fast", function() {
                var cs = $(this.parentNode).attr("class").replace("slideDown", "")
                $(this.parentNode).attr("class", cs)
            });
        } else {

            //                    alert($(this.parentNode).find(" :has(dl)").length);
            //                    alert($(this.parentNode).find("dd").not($.makeArray($(this.parentNode).find("dd dd"))).length);
            //alert($(this.parentNode).find("dd").not($(this.parentNode).find("dd:has(dl)").to).length);


            $(this.parentNode).find("dd").not($.makeArray($(this.parentNode).find("dd dd"))).slideUp("fast", function() {
                if (!$(this.parentNode).hasClass("slideDown")) {
                    var cs = $(this.parentNode).attr("class") + " slideDown";
                    $(this.parentNode).attr("class", cs)
                }
            });
        }
    }
            );
});



function doPage(url) {
    window.location = url;
    //window.parent.doPage(url);
}
function GoBack() {
    window.history.back();
}



function _openExpertService(id) {
    window.open('/expert/tolc.aspx?id=' + id, 'tolc' + id,
     'menubar=no,scrollbars=yes,resizable=yes,location=no,toolbar=no,width=690,height=500', true);
}
          

var lastMoveObj = null;
var moveTig = 0;
var slideCallBack = null;
var _slideTimeoutRun = false;
function _slideTimeout() {
    if (moveTig == 0 && lastMoveObj != null && slideCallBack != null) {
        slideCallBack(lastMoveObj);
        lastMoveObj = null;
        slideCallBack = null;
    } else {
        moveTig--;
    }

}
$(function() {
    setInterval("_slideTimeout()", 100);
    SlideInit();
    SetImgAutoSize();
    
});
$(function() {
SetImgAutoSize();
});
function SlideInit() {
    $(".board").each(function() {
        var board = this;

        var callBack = function(obj) {

            $(board).find("dd.slide").hide();
            $(board).find("a.slide").removeClass("active");
            var bind = $("." + $(obj).attr("bind"));
            bind.show();
            $(obj).addClass("active");
            if(bind.length>0)
                SetImgAutoSize1(bind[0]);

        };
        $(board).find("dt a.slide").mouseover(function() {
            if (lastMoveObj == this) {
                return;
            }
            else {
                lastMoveObj = this;
                slideCallBack = callBack;
                moveTig = 3;
                //                    _slideTimeout();
            }
        });
        $(board).find("dt a.slide").mouseout(function() {
            if (lastMoveObj == this) {
                lastMoveObj = null;
                slideCallBack = null;
            } else {
            }
        });

    });
}
function SetImgAutoSize1(obj) {
 
    $(obj).find(".autoSizeImg").each(function() {
        var max_w = $(this.parentNode.parentNode).width();
        var max_h = $(this.parentNode.parentNode).height();
        var m1 = max_w / max_h;
        var m2 = $(this).width() / $(this).height();
        if (m2 > m1) {
            $(this).width(max_w);
            var mt = (max_h - $(this).height()) / 2;
            $(this).css({ "margin-top": mt });
        } else {
            $(this).height(max_h);
        }
    });

}
function SetImgAutoSize() {
    $(".autoSizeImgC .autoSizeImg").each(function() {
        if ($(this).width() > 0) {
            var max_w = $(this.parentNode.parentNode).width();
            var max_h = $(this.parentNode.parentNode).height();

            var m1 = max_w / max_h;
            var m2 = $(this).width() / $(this).height();

            if (m2 > m1) {
                $(this).width(max_w);
                var mt = (max_h - $(this).height()) / 2;
                $(this).css({ "margin-top": mt });
            } else {
                $(this).height(max_h);
            }
        }
    });
}
 